package main

import (
	"flag"
	"fmt"
	"net/http"
	"os"
)

var (
	shareDir *string
	port     *string
)

func init() {
	shareDir = flag.String("dir", "/", "want to share directry")
	port = flag.String("port", "8000", "http listen port")
	flag.Parse()
}

func main() {
	if *shareDir == "/" {
		*shareDir, _ = os.Getwd()
	}

	h := http.FileServer(http.Dir(*shareDir))
	if err := http.ListenAndServe(":"+*port, h); err != nil {
		fmt.Println(err)
	}
}
